cmake_minimum_required(VERSION 3.5)

project(tensorrt-yolox)

set(CUDA_PATH /usr/local/cuda)
set(TENSORRT_PATH /path/to/TensorRT)

set(SOURCES_PATH src)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")

add_compile_options(-Wno-unused-function)

find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})
link_directories(${OpenCV_LIBS})

add_library(opencv INTERFACE)
target_include_directories(opencv INTERFACE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(opencv INTERFACE ${OpenCV_LIBS})

add_library(cuda INTERFACE)
target_include_directories(cuda INTERFACE ${CUDA_PATH}/include/)
link_directories(${CUDA_PATH}/lib64)
target_link_libraries(cuda INTERFACE 
        libcudart.so 
        libcublas.so
        libcurand.so
        libcusolver.so
        libcusparse.so
    )

add_library(tensorrt INTERFACE)
target_include_directories(tensorrt INTERFACE ${TENSORRT_PATH}/include)
link_directories(${TENSORRT_PATH}/lib)
target_link_libraries(tensorrt INTERFACE 
        libnvinfer.so 
        libnvinfer_plugin.so
        libnvparsers.so 
        libnvonnxparser.so
    )

file(GLOB_RECURSE SOURCES_FILES ${SOURCES_PATH}/*.h ${SOURCES_PATH}/*.cc)
add_executable(tensorrt_yolox ${SOURCES_FILES})
target_include_directories(tensorrt_yolox PUBLIC ${SOURCES_PATH})
target_link_libraries(tensorrt_yolox cuda tensorrt opencv)

